package com.x.client.fragment

import android.view.View
import com.alibaba.android.arouter.launcher.ARouter
import com.gg.baselibrary.BaseFragment
import com.gg.utils.StatusUtils
import com.gg.utils.toast
import com.jakewharton.rxbinding2.view.RxView
import com.x.client.R
import com.x.client.utils.RouterClass
import com.x.client.utils.UIHelper
import kotlinx.android.synthetic.main.fragment_my.*
import java.util.concurrent.TimeUnit

/**
 * Creator : GG
 * Date    : 2018/5/21
 * Mail    : gg.jin.yu@gmai.com
 * Explain :
 */
class MyFragment : BaseFragment() {

    companion object {
        fun newInstance() = MyFragment()
    }

    override fun getLayoutResId(): Int = R.layout.fragment_my

    override fun initView() {
        super.initView()
        statusBar.layoutParams.apply {
            height = StatusUtils.getStatusBarHeight(context!!)
        }


        RxView.clicks(setting)
                .throttleFirst(500, TimeUnit.MICROSECONDS)
                .compose(this.bindToLifecycle())
                .subscribe {
                    ARouter.getInstance()
                            .build(RouterClass.setting)
                            .navigation()
                }

        RxView.clicks(collection)
                .throttleFirst(500, TimeUnit.MICROSECONDS)
                .compose(this.bindToLifecycle())
                .subscribe {
                    toast("collection")
                }

        RxView.clicks(subscribe)
                .throttleFirst(500, TimeUnit.MICROSECONDS)
                .compose(this.bindToLifecycle())
                .subscribe {
                    toast("subscribe")

                }

        RxView.clicks(history)
                .throttleFirst(500, TimeUnit.MICROSECONDS)
                .compose(this.bindToLifecycle())
                .subscribe {
                    toast("history")

                }

        RxView.clicks(myMessage)
                .throttleFirst(500, TimeUnit.MICROSECONDS)
                .compose(this.bindToLifecycle())
                .subscribe {
                    ARouter.getInstance()
                            .build(RouterClass.message)
                            .navigation()
                }


        with(UIHelper) {
            setAccessible(view = shareQy, text = getString(R.string.share_qy), onClickListener = View.OnClickListener {
                toast("----------")
            })

            setAccessible(view = contactService, text = getString(R.string.contact_service), onClickListener = View.OnClickListener {

            })

            setAccessible(view = feedback, text = getString(R.string.feedback), onClickListener = View.OnClickListener {
                ARouter.getInstance()
                        .build(RouterClass.feedback)
                        .navigation()
            })

            setAccessible(view = aboutUs, text = getString(R.string.about_us), onClickListener = View.OnClickListener {
                ARouter.getInstance()
                        .build(RouterClass.aboutUs)
                        .navigation()
            })
        }

    }

}